﻿// -------------------------------------------------------------------------------------------------------------------------------
// <copyright file="DiagonalMatrixFactorRingOperationsProvider.cs" company="Exul">
//     Copyright (c) Exul. All rights reserved.
// </copyright>
// <author>
//     Exul
// </author>
// -------------------------------------------------------------------------------------------------------------------------------

namespace ExulLibrary.Mathematics.LinearAlgebra.Sequential.DecimalExtensions
{
    #region Usings

    using System;

    #endregion

    /// <summary>
    ///     Provides operations for <see cref="DiagonalMatrix{T}"/> through interface.
    /// </summary>
    internal sealed class DiagonalMatrixFactorRingOperationsProvider
        : IMatrixFactorRingOperationsProvider<decimal>
    {
        #region Implemented Interfaces

        #region IMatrixFactorRingOperationsProvider<decimal>

        /// <summary>
        ///     Adds the specified factor to all elements of the matrix.
        /// </summary>
        /// <param name="matrix">
        ///     The matrix whose elements should be added.
        /// </param>
        /// <param name="factor">
        ///     The factor to add.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="matrix"/> is <see langword="null"/>.
        /// </exception>
        public void Add(Matrix<decimal> matrix, decimal factor)
        {
            var realMatrix = matrix as DiagonalMatrix<decimal>;
            realMatrix.Add(factor);
        }

        /// <summary>
        ///     Multiplies all elements of the matrix by the specified factor.
        /// </summary>
        /// <param name="matrix">
        ///     The matrix whose elements should be multiplied.
        /// </param>
        /// <param name="factor">
        ///     The factor to multiply.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="matrix"/> is <see langword="null"/>.
        /// </exception>
        public void Multiply(Matrix<decimal> matrix, decimal factor)
        {
            var realMatrix = matrix as DiagonalMatrix<decimal>;
            realMatrix.Multiply(factor);
        }

        #endregion

        #endregion
    }
}